#include<bits/stdc++.h>
using namespace std;
int n,m,L,V,ans1,ans2,d[31],v[31],a[31],p[31],b[31];
int check(int d,int v,int a,int last)
{
    if(v>V)
    {
        if(a>=0)
        {
            if(d<=p[last]) return 1;
        }
        else
        {
            double t=1.0*(V-v)/a,s=1.0*(v*t+0.5*a*t*t)+d;
            //cout<<d<<" "<<v<<" "<<a<<" "<<t<<" "<<s<<endl;
            for(int j=1;j<=m;j++)
            {
                if(b[j]) continue;
                if(p[j]>=d&&p[j]<=s) return 1;
            }
        }
    }
    else
    {
        if(a>0)
        {
            double t=1.0*(V-v)/a,s=1.0*(v*t+0.5*a*t*t+d);
            if(s<p[last])
            {
                return 1;
            }
        }
    }
    return 0;
}
void dfs(int dep,int s)
{
    //cout<<dep<<" "<<s<<endl;
    if(dep>m)
    {
        if(s==0) return ;
        int cnt=0,last=0;
        for(int i=m;i>=1;i--)
        {
            if(b[i]) continue;
            last=i;
            break;
        }
        for(int i=1;i<=n;i++) cnt+=check(d[i],v[i],a[i],last);
        if(cnt==ans1)
        {
            //cout<<last<<endl;
            //for(int i=1;i<=m;i++) cout<<b[i]<<" ";
            //cout<<endl;
            ans2=max(ans2,s);
        }
        return ;
    }
    b[dep]=0;
    dfs(dep+1,s);
    b[dep]=1;
    dfs(dep+1,s+1);
    b[dep]=0;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        memset(b,0,sizeof(b));
        ans1=0,ans2=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++) cin>>p[i];
        for(int i=1;i<=n;i++) ans1+=check(d[i],v[i],a[i],m);
        dfs(1,0);
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}
